// LSL script generated: RLV-New.Addons.DV_MAIN_Sign.lslp Sun May  2 00:09:51 Westeuropäische Sommerzeit 2010
list gMenu = [];
list statesMenu = [0,0,0,0];
key ToucherID;
integer channel_dialog;
integer listen_id;
string msg;
list color = ["Pink","White","Black","Red","Blue"];
integer random;
vector gColor;
string gMessage = "♥";
//
displayMenu(){
    (gMenu = []);
    (gMenu += "Back");
    (gMenu += "Set New");
    if ((llList2Integer(statesMenu,0) == 1)) (gMenu += "[x]Hide");
    else  (gMenu += "[ ]Hide");
    (gMenu += color);
    (msg = "Pick one");
    (channel_dialog = (-1 * ((integer)("0x" + llGetSubString(((string)llGetKey()),-5,-1)))));
    (listen_id = llListen(channel_dialog,"",NULL_KEY,""));
    llDialog(ToucherID,msg,gMenu,channel_dialog);
    llSetTimerEvent(45.0);
}

MakeRLVState(){
    {
        if ((llList2Integer(statesMenu,0) == 1)) llMessageLinked(-1,1235,"off",NULL_KEY);
    }
}

llLRP(integer element_new,integer placeinlist){
    (statesMenu = llListReplaceList(statesMenu,[element_new],placeinlist,placeinlist));
}

default {

    state_entry() {
    }

     listen(integer channel,string name,key id,string message) {
        if ((channel == channel_dialog)) {
            llListenRemove(listen_id);
            if ((message == "Pink")) {
                (gColor = <1.0,0.0,1.0>);
                llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
                displayMenu();
            }
            else  if ((message == "White")) {
                (gColor = <1.0,1.0,1.0>);
                llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
                displayMenu();
            }
            else  if ((message == "Black")) {
                (gColor = <0.0,0.0,0.0>);
                llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
                displayMenu();
            }
            else  if ((message == "Red")) {
                (gColor = <1.0,0.0,0.0>);
                llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
                displayMenu();
            }
            else  if ((message == "Blue")) {
                (gColor = <0.0,0.0,1.0>);
                llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
                displayMenu();
            }
            else  if ((message == "Set New")) {
                float grand = llFrand(13333337);
                (random = llRound(grand));
                (listen_id = llListen(random,"",ToucherID,""));
                llInstantMessage(ToucherID,("Set new Sign on:" + ((string)random)));
            }
            else  if ((message == "Back")) {
                llMessageLinked(-4,1337,"DV_MAIN_MISC",ToucherID);
            }
            else  if ((message == "[x]Hide")) {
                llMessageLinked(-1,1235,"on",NULL_KEY);
                llLRP(0,0);
                displayMenu();
            }
            else  if ((message == "[ ]Hide")) {
                llLRP(1,0);
                llMessageLinked(-1,1235,"off",NULL_KEY);
                displayMenu();
            }
        }
        if ((channel == random)) {
            (gMessage = message);
            llMessageLinked(-1,1234,((gMessage + "||") + ((string)gColor)),NULL_KEY);
        }
    }

    
    link_message(integer sender,integer num,string str,key id) {
        if ((num == 1337)) {
            if ((str == llGetScriptName())) {
                llMessageLinked(-4,1338,llGetScriptName(),NULL_KEY);
                (ToucherID = id);
                displayMenu();
            }
        }
        if ((num == 1338)) {
            if ((str != llGetScriptName())) {
                llListenRemove(listen_id);
            }
        }
        if ((num == 1339)) {
            if ((str == "ON_REZ")) {
                MakeRLVState();
            }
            if ((str == "RESET")) {
                (statesMenu = [0,0,0,0,0,0,0,0,0,0]);
            }
        }
    }

  	
  	on_rez(integer num) {
    }

  	

  	
  	timer() {
        llSetTimerEvent(0.0);
        llListenRemove(listen_id);
    }
}
